#ifndef SHENLAN_GOVERTEX
#define SHENLAN_GOVERTEX

#include "Assets/ZResourcesLib/shaders/common/shenlan_simple_function.hlsl"

float3 vertexgoAxis(float3 vertex, float4 offset, float4 offset2, float move)
{
    
    float random = lerp(0, frac(vertex.x * 37.82 + vertex.y * 7.8415), offset.z);//随机值
    float2 l = sign(offset.x) * vertex.xy * offset.y - move;//偏移的程度+随机值
    float2 lrot = l + random * 0.5;//偏移的程度+随机值
    #ifdef _XORY_GV_ON
        float2 moveDis = float2(0, offset.x);//偏移终点
        float2 moveDisRam = moveDis * saturate(lrot);//偏移
        float2 rot = mul(RotateMatrix(min(offset2.z * max(lrot.y, 0), 360 * ceil(offset2.z / 360))), vertex.xz);//旋转
        float scale = lerp(1, offset2.w, saturate(lrot.x));
        vertex = float3(rot.x, vertex.y, rot.y) * scale ;
    #else
        float2 moveDis = float2(offset.x, 0);//偏移终点
        float2 moveDisRam = moveDis * saturate(lrot);//偏移
        float2 rot = mul(RotateMatrix(min(offset2.z * max(lrot.x, 0), 360 * ceil(offset2.z / 360))), vertex.yz);//旋转
        float scale = lerp(1, offset2.w, saturate(lrot.x));
        vertex = float3(vertex.x, rot) * scale ;
    #endif
    return vertex + float3(moveDisRam, 0);
}

float4 vertexgoAxisColorDis(float2 vertex, float2 vertexO, float4 offset, float4 offset2)
{
    //vertex 偏移后的顶点 vertexO 偏移前的顶点
    
    float random = lerp(0, frac(vertexO.x * 37.82 + vertexO.y * 7.8415), saturate(offset.w) * 2);

    #ifdef _XORY_GV_ON
        float2 colorDis = sign(offset.x) * vertex * offset2.x * float2(0, 1);
    #else
        float2 colorDis = sign(offset.x) * vertex * offset2.x * float2(1, 0);
    #endif

    float4 finalvalue = float4(colorDis + random - offset2.y - 1, colorDis - offset2.y);
    return finalvalue;
}

half4 vertexgoAxisColor(float4 posLocal, half4 moveColor)
{
    half4 colFactor = half4(length(max(0, posLocal.zw)).xxx, length(max(0, posLocal.xy)));
    half4 finalvalue = lerp(1, moveColor, saturate(colFactor));
    return finalvalue;
}

#endif